
***Log file
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Replication\Log files\Main Figures"
clear all
log using Fig4.log, replace

***Figure 4: OLS evolution of profitability: Completed vs withdrawn
clear
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Data"
use LPSU_MainSample_Sep2024, replace

***Set of fixed effects
qui tabulate year_around_ipo, generate(deventyear) 

**Create a random variable with mean 0, to include as "benchmark" coefficient of 0 on t=-1. All other event-years will be relative to t=-1
set seed 123
generate randnum = uniform()-0.5

**Program to save coefficients
capture program drop foo
program foo, eclass
	tempname bmat
    tempname vmat
	matrix `bmat' = e(b)
	matrix `bmat'[1,1] = 0
	matrix `vmat' = e(V)
	matrix `vmat'[1,1] = 0
	ereturn repost b = `bmat'
	ereturn repost V = `vmat'
end
label var randnum "-1"

*Label fixed effects
label var deventyear1 "-2"
label var deventyear3 "0"
label var deventyear4 "1"
label var deventyear5 "2"


**Defining events
gen ipo_ev1=deventyear1*ipo
gen ipo_ev3=deventyear3*ipo
gen ipo_ev4=deventyear4*ipo
gen ipo_ev5=deventyear5*ipo
gen noipo_ev1=deventyear1*(1-ipo)
gen noipo_ev3=deventyear3*(1-ipo)
gen noipo_ev4=deventyear4*(1-ipo)
gen noipo_ev5=deventyear5*(1-ipo)

*Label events x IPO and Failed IPOs
label var ipo_ev1 "-2"
label var noipo_ev1 "-2"
label var ipo_ev3 "0"
label var noipo_ev3 "0"
label var ipo_ev4 "1"
label var noipo_ev4 "1"
label var ipo_ev5 "2"
label var noipo_ev5 "2"


**First, keepcoefficients for Completed IPOs
set more off
qui xtreg wroa randnum ipo_ev1 noipo_ev1 ipo_ev3 noipo_ev3 ipo_ev4 noipo_ev4 ipo_ev5 noipo_ev5, fe cluster(id) 
foo
estimate store ipo



**Repeating but for withdrawn IPOs
drop ipo_* noipo_*

gen ipo_ev1=deventyear1*(1-ipo)
gen ipo_ev3=deventyear3*(1-ipo)
gen ipo_ev4=deventyear4*(1-ipo)
gen ipo_ev5=deventyear5*(1-ipo)
gen noipo_ev1=deventyear1*ipo
gen noipo_ev3=deventyear3*ipo
gen noipo_ev4=deventyear4*ipo
gen noipo_ev5=deventyear5*ipo

label var ipo_ev1 "-2"
label var noipo_ev1 "-2"
label var ipo_ev3 "0"
label var noipo_ev3 "0"
label var ipo_ev4 "1"
label var noipo_ev4 "1"
label var ipo_ev5 "2"
label var noipo_ev5 "2"


**Next, keep coefficients for withdrawn IPOs
set more off
qui xtreg wroa randnum ipo_ev1 noipo_ev1 ipo_ev3 noipo_ev3 ipo_ev4 noipo_ev4 ipo_ev5 noipo_ev5, fe cluster(id) 
foo
estimate store noipo




**Figure #4. Profitability by Event-year for Completed and Withdrawn IPOs
*"randnum" will take the place of t=-1. 
coefplot (ipo,yline(0) clpattern(shortdash) msymbol(C) msize(large))  (noipo , msymbol(T) msize(large)), ///
keep(randnum ipo_ev1 ipo_ev3 ipo_ev4 ipo_ev5) /// 
order( ipo_ev1 randnum ipo_ev3 ipo_ev4 ipo_ev5) ///
 yline(0)  clpattern(shortdash)  ciopts(recast(rcap) clpattern(shortdash))  ///
 citop vertical  title(OROA coefficients around IPO attempts)  subtitle (Completed vs withdrawn IPOs)   ///
 plotlabels( "Completed IPOs" "Withdrawn IPOs" ) xline(2.5, lpattern(dash) lcolor(black)) ysc(r(-0.08 0.04)) ylab(-0.08(0.04)0.04) 
 
graph export "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Figures\OROA_compl_with.tif", as(tif) replace 
 
graph export Fig4.pdf, replace  
 
***Log file
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Replication\Log files\Main Figures"
log close
graphlog using Fig4.log, lspacing(1) replace
